import fetch from '@/utils/fetch';

export function getList(query) {
    query._ts = (new Date()).getTime();
    return fetch({
        url: '/operator/course/list',
        method: 'get',
        params: query
    });
}

export function getDetail(courseId) {
    var _ts = (new Date()).getTime();
    return fetch({
        url: '/operator/course/detail',
        method: 'get',
        params: {
            courseId,
            _ts
        }
    });
}

export function getCategorys(courseId) {
    var _ts = (new Date()).getTime();
    return fetch({
        url: '/operator/course/categorys',
        method: 'get',
        params: {
            courseId,
            _ts
        }
    });
}

export function add(course) {
    return fetch({
        url: '/operator/course/add',
        method: 'post',
        data: course
    });
}

export function update(course) {
    return fetch({
        url: '/operator/course/update',
        method: 'post',
        data: course
    });
}

export function toggleStatus(courseId, status) {
    return fetch({
        url: '/operator/course/status/toggle',
        method: 'post',
        data: {
            courseId,
            status
        }
    });
}

export function updateSerial(courseId, serial) {
    return fetch({
        url: '/operator/course/serial/update',
        method: 'post',
        data: {
            courseId,
            serial
        }
    });
}